package com.abso.mp3tunes.locker.ui.preferences;

import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;

import com.abso.mp3tunes.locker.ui.ILockerConstants;
import com.abso.mp3tunes.locker.ui.LockerPlugin;

/**
 * The MP3tunes Locker preference page.
 * 
 */
public class LockerPreferencePage extends FieldEditorPreferencePage implements
		IWorkbenchPreferencePage {

	/** Constructs a new page. */
	public LockerPreferencePage() {
		super(GRID);
		setPreferenceStore(LockerPlugin.getDefault().getPreferenceStore());
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
	 */
	public void init(IWorkbench workbench) {
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
	 */
	protected void createFieldEditors() {
		FieldEditor usernameField = new StringFieldEditor(ILockerConstants.PREF_USERNAME,
				"Locker Username:", getFieldEditorParent()) {
			public void loadDefault() {
				// does nothing (we don't want to clear the field
			}
		};
		addField(usernameField);
		FieldEditor passwordField = new PasswordFieldEditor(ILockerConstants.PREF_PASSWORD,
				"Locker Password:", getFieldEditorParent()) {
			public void loadDefault() {
				// does nothing (we don't want to clear the field
			}
		};
		addField(passwordField);
		FieldEditor timeoutField = new IntegerFieldEditor(ILockerConstants.PREF_TIMEOUT,
				"Connection Timeout (ms):", getFieldEditorParent());
		addField(timeoutField);
		FieldEditor chunkSizeField = new IntegerFieldEditor(ILockerConstants.PREF_CHUNK_SIZE,
				"Request Chunk Size:", getFieldEditorParent());
		addField(chunkSizeField);
	}

}
